﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BussinessObject;
using Class_Entity;
using DataAccess;

public partial class Place_Managerment : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            BlindProductToGridview();

        }

    }
    protected void BlindProductToGridview()
    {
        BO_Place bopl1 = new BO_Place();
        CE__Place cepl1 = new CE__Place();

        GridView1.DataSource = bopl1.Load_Place(cepl1);
        GridView1.DataBind();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BO_Place bopl = new BO_Place();
        CE__Place cepl = new CE__Place();

        int id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[0].Text);
        cepl._PlaceID = id;
        bopl.Delete_Place(cepl);
        BlindProductToGridview();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BlindProductToGridview();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        BO_Place bopl = new BO_Place();
        CE__Place cepl = new CE__Place();

        string idtxt = ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text;
        int id = Convert.ToInt32(idtxt);
        cepl._PlaceID = Convert.ToInt32(idtxt);
        cepl._PlaceName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
        bopl.Update_Place(cepl);
        GridView1.EditIndex = -1;
        BlindProductToGridview();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        BlindProductToGridview();
    }
}